package com.smart.manager.finance.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.smart.common.entities.ajax.AjaxResult;
import com.smart.common.entities.constant.SmartConstant;
import com.smart.common.entities.core.Page;
import com.smart.manager.finance.entities.bodys.RPopApply;
import com.smart.manager.finance.entities.models.FinancePopApply;
import com.smart.manager.finance.repository.ApplyRepository;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


@Api(tags = "提现管理")
@RestController
@RequestMapping(SmartConstant.MANAGER_API_PREFIX + "finance/pop/apply")
@RequiredArgsConstructor
public class ApplyApi {

    private final ApplyRepository applyRepository;

    @GetMapping(value = "pageList")
    @ApiOperation(value = "查询提现")
    @SaCheckPermission("finance:pop:apply:pageList")
    public AjaxResult<Page<FinancePopApply>> pageList(@Validated RPopApply.SearchBody body) {
        Page<FinancePopApply> result = applyRepository.pageList(body);
        return AjaxResult.data(result);
    }

    @PutMapping(value = "process/{id}")
    @ApiOperation(value = "处理提现")
    @SaCheckPermission("finance:pop:apply:process")
    public AjaxResult<String> update(@PathVariable Long id,@RequestBody @Validated RPopApply.EditBody body) {
        applyRepository.process(id,body);
        return AjaxResult.success();
    }

}
